interface Items {
    [propName: string]: string
}

const parseQueryStr = (data:Items | any, decode:boolean = true) => {
    return Object.keys(data).sort().map(key => {
        let value = data[key];
        value = decode ? encodeURIComponent(value) : value;
        return `${key}=${value}`;
    }).join(`&`);
}

export default parseQueryStr;